package com.sale.goods.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.sale.common.core.domain.R;
import com.sale.common.core.web.controller.BaseController;
import com.sale.common.mybatis.core.page.PageQuery;
import com.sale.common.mybatis.core.page.TableDataInfo;
import com.sale.goods.domain.dto.SysDateChangeDto;
import com.sale.goods.domain.vo.GetViewVo;
import com.sale.goods.domain.vo.SysDateChangeVo;
import com.sale.goods.service.SysDateChangeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

/**
 * 日期变更控制层
 */
@RestController
@RequestMapping("/sys-date-change")
public class SysDateChangeController extends BaseController {

    @Resource
    SysDateChangeService sysDateChangeService;

    /**
     * 日期变更分页列表
     */
    //@SaCheckPermission("finance:dateChange:list")
    @GetMapping("/list")
    public TableDataInfo<SysDateChangeDto> getList(SysDateChangeVo sysDateChangeVo, PageQuery pageQuery) {
        return sysDateChangeService.getList(sysDateChangeVo, pageQuery);
    }

    /**
     * 日期变更新增
     */
    //@SaCheckPermission("finance:dateChange:add")
    @PostMapping("/add")
    public R<?> addSysDateChange(@RequestBody SysDateChangeVo sysDateChangeVo) {
        return toAjax(sysDateChangeService.addSysDateChange(sysDateChangeVo));
    }

    /**
     * 查询获取单据详情
     */
    //@SaCheckPermission("finance:dateChange:query")
    @GetMapping("/getView")
    public R<SysDateChangeDto> getView(GetViewVo getViewVo) throws ParseException {
        return R.ok(sysDateChangeService.getView(getViewVo));
    }
}
